package com.ybt.message.unpack;

import org.jdom.Element;

import com.ruleengine.context.IWorkflowConext;
import com.ybt.message.unpack.exception.MessageUnpackException;

public abstract class MessageUnpackDecorator implements IMessageUnpack {

    IMessageUnpack unpack;
    protected Element config;
    
    public MessageUnpackDecorator(IMessageUnpack unpack) {
        super();
        this.unpack = unpack;
    }

    public void setUnpackConfig(Element config) {
        this.config = config;
    }

    public Object unpack(IWorkflowConext context, Object message)
            throws MessageUnpackException{
        Object result = unpack.unpack(context, message);
        return unpackMessage(context, result);
    }

    public abstract Object unpackMessage(IWorkflowConext context, Object message)
    throws MessageUnpackException;
}
